package cn.shu;

/**
 * Created by 76062 on 2017/9/22.
 */
public class SynchronizedCode implements Runnable {
    private int aa;

    public SynchronizedCode(int aa){
        this.aa = aa;
    }

    public void run() {
        synchronized (SynchronizedCode.class){
            try {
                System.out.println("@@"+aa);
                Thread.sleep(aa);
                System.out.println("----"+aa);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args){
        SynchronizedCode sc1 = new SynchronizedCode(2000);
        SynchronizedCode sc2 = new SynchronizedCode(1000);
        Thread thread1 = new Thread(sc1);
        Thread thread2 = new Thread(sc2);
        thread1.start();
        thread2.start();
    }

}
